package com.qidian.zl.paper.service.impl;

import com.qidian.zl.paper.dao.SelectorDAO;
import com.qidian.zl.paper.factory.DAOFactory;
import com.qidian.zl.paper.pojo.Selector;
import com.qidian.zl.paper.service.SelectorService;
import com.qidian.zl.paper.util.StCache;

import java.util.List;

public class SelectorServiceImpl implements SelectorService {
    private SelectorDAO selectorDAO= DAOFactory.getSelectorDAO();
    @Override
    public List<Selector> queryByFieldId(long fieldId) {
        List<Selector> selectors=null;
        String key="selectors_"+fieldId;
        if (StCache.cache(key)){
            selectors=(List<Selector>) StCache.get(key);
        }else {
            selectors= selectorDAO.queryFieldId(fieldId);
            StCache.put(key,selectors);
        }
        return selectors;
    }
}
